<!DOCTYPE html>
<!--
Copyright (c) 2020 The Chromium Authors. All rights reserved.
Use of this source code is governed by a BSD-style license that can be
found in the LICENSE file.
-->

<link rel="import" href="/tracing/core/test_utils.html">
<link rel="import" href="/tracing/extras/importer/linux_perf/ftrace_importer.html">

<script>
'use strict';

tr.b.unittest.testSuite(function() {
  test('temperature', function() {
    const lines = [
      'kworker/u17:2-13403 (13403) [000] ....  6083.392723: ' +
          'thermal_temperature: thermal_zone=tz1 id=0 temp_prev=40000 ' +
          'temp=39000',

      'kworker/u17:3-18821 (18821) [000] ....  6086.464415: ' +
          'thermal_temperature: thermal_zone=tz1 id=0 temp_prev=39000 ' +
          'temp=58000',

      'kworker/u19:3-20316 (20316) [000] ....  6086.551408: ' +
          'thermal_temperature: thermal_zone=tz1 id=0 temp_prev=60000 ' +
          'temp=52000',
    ];

    const m = tr.c.TestUtils.newModelWithEvents([lines.join('\n')], {
      shiftWorldToZero: false
    });
    assert.isFalse(m.hasImportWarnings);

    const counters = m.getAllCounters();
    assert.strictEqual(counters.length, 1);

    assert.strictEqual(counters[0].series[0].samples.length, 3);
  });

  test('cdev', function() {
    const lines = [
      'kworker/u17:2-13403 (13403) [000] ....  6083.457060: cdev_update: ' +
          'type=cpu0 target=0',

      'kworker/u17:2-13403 (13403) [000] ....  6083.458060: cdev_update: ' +
          'type=cpu0 target=1',

      'kworker/u17:2-13403 (13403) [000] ....  6083.459060: cdev_update: ' +
          'type=cpu0 target=0',
    ];

    const m = tr.c.TestUtils.newModelWithEvents([lines.join('\n')], {
      shiftWorldToZero: false
    });
    assert.isFalse(m.hasImportWarnings);

    const counters = m.getAllCounters();
    assert.strictEqual(counters.length, 1);

    assert.strictEqual(counters[0].series[0].samples.length, 3);
  });
});
</script>
